package com.pega.eprescription.activity;

import java.util.ArrayList;
import java.util.List;

import com.pega.eprescription.R;
import com.pega.eprescription.database.model.Pill;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AlarmDialogListAdapter extends BaseAdapter {

	public List<Pill> m_listPill;
	private Context m_context;

	public AlarmDialogListAdapter() {
		m_listPill = new ArrayList<Pill>();
	}

	public AlarmDialogListAdapter(Context context, List<Pill> listPill) {
		m_listPill = new ArrayList<Pill>();
		m_listPill.clear();
		m_listPill.addAll(listPill);
		m_context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return m_listPill.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(final int index, View convertView,
			final ViewGroup parent) {
		// TODO Auto-generated method stub
		final Pill pill = m_listPill.get(index);

		LayoutInflater infalInflater = (LayoutInflater) m_context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		convertView = infalInflater.inflate(R.layout.alarm_dialo_list_item,
				null);

		convertView.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
			}
		});

		ImageView pillPicture = (ImageView) convertView
				.findViewById(R.id.iv_pill_picture);
		// syncBtn.setBackground(m_context.getResources().getDrawable(R.drawable.survey_sync_btn);

		TextView pillName = (TextView) convertView
				.findViewById(R.id.tv_pill_name);
		pillName.setText(pill.getNamePill());

		//
		// if(survey.avatar != null)
		// {
		// ImageView surveyAvatar =
		// (ImageView)convertView.findViewById(R.id.survey_avatar);
		// surveyAvatar.setImageBitmap(survey.avatar);
		// }
//		if (index % 2 == 0)
//			convertView.setBackgroundResource(R.color.Icon);
		return convertView;
	}

}
